home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0041_Getting Key Stats.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  1KB  |  71 lines

  1. { ROB PERELMAN }
  2.  
  3. Unit KeyStats;
  4.  
  5. Interface
  6.  
  7. Function RightShift : Boolean;
  8. Function LeftShift  : Boolean;
  9. Function Control    : Boolean;
  10. Function Alt        : Boolean;
  11. Function ScrollLock : Boolean;
  12. Function NumLock    : Boolean;
  13. Function CapsLock   : Boolean;
  14. Function Insert     : Boolean;
  15.  
  16. Implementation
  17.  
  18. Uses
  19.   Dos;
  20.  
  21. Function ShiftState : Byte;
  22. Var
  23.   Regs : Registers;
  24. begin
  25.   Regs.Ah := 2;
  26.   Intr($16, Regs);
  27.   ShiftState := Regs.Al;
  28. end;
  29.  
  30. Function RightShift : Boolean;
  31. begin
  32.   RightShift := (ShiftState and 1) <> 0;
  33. end;
  34.  
  35. Function LeftShift : Boolean;
  36. begin
  37.   LeftShift := (ShiftState and 2) <> 0;
  38. end;
  39.  
  40. Function Control : Boolean;
  41. begin
  42.   Control := (ShiftState and 4) <> 0;
  43. end;
  44.  
  45. Function Alt : Boolean;
  46. begin
  47.   Alt := (ShiftState and 8) <> 0;
  48. end;
  49.  
  50. Function ScrollLock : Boolean;
  51. begin
  52.   ScrollLock := (ShiftState and 16) <> 0;
  53. end;
  54.  
  55. Function NumLock : Boolean;
  56. begin
  57.   NumLock := (ShiftState and 32) <> 0;
  58. end;
  59.  
  60. Function CapsLock : Boolean;
  61. begin
  62.   CapsLock := (ShiftState and 64) <> 0;
  63. end;
  64.  
  65. Function Insert : Boolean;
  66. begin
  67.   Insert := (ShiftState and 128) <> 0;
  68. end;
  69.  
  70. end.
  71.